// Category.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    banners: [],
    typeList: ["包子", "汤类", "包子"],
    selectIndex: 0,
    isSmartShow: false,
    smartIndex0: 0,
    smartIndex1:0,
    selectedArray:[-1,-1,2]

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    // //类别
    // var categoryType = options.categoryType
    // var title = '暖心早餐'
    // if (categoryType == 2) {
    //   title = '极速外卖'
    // } else if (categoryType == 3) {
    //   title = '花样零售'
    // }
    wx.setNavigationBarTitle({
      title: "全部分类",
    })
    //查询今日首推进行渲染显示
    wx.request({
      url: app.data.ipconfig + '/wxxiaochengxu/homebannerApi/getDevaluationList',
      data: { appid: app.data.appid, openid: wx.getStorageSync('openid') },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        console.log(res.data.res)
        that.setData({
          todayShops: res.data.res
        })
      },
      fail: function () {
        console.log("接口出现异常");
      }
    })

    

  },
  loadMore: function () {

    console.log("加载更多");
  },
  ///服务详情
  serviceDetail: function () {
 
    wx.navigateTo({
      url: '../../pages/serviceDetail/serviceDetail',
    })

   
  },
  

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  /**
   * 价格排序
   */
  priceOrderClick: function () {
    var that = this;
    //获取当前的状态
    if (that.data.priceOrderSelected == 'up') {

      that.setData({

        priceOrderSelected: 'down'
      })
    } else {
      that.setData({

        priceOrderSelected: 'up'
      })
    }



  },
  
  smartViewClick: function() {
    var that = this;
    that.setData({
      isSmartShow: true,
     
    })
  },
  closeView: function () {
    var that = this;
    that.setData({
      isSmartShow: false,
      
    })
  },
  nocloseView: function (e) {
    //e.stopPropagation();
  },
  clickCategory: function (e) {
    // 点击了分类
    var that = this
    var index = e.currentTarget.dataset.index
    //获取当前选中的商品列表
    var currentTypeGoods = that.data.typeList[index].items
    that.setData({
      selectIndex: index,
      currentTypeGoods: currentTypeGoods
    })
  },
 
  clickItem: function (e) {
    console.log(e)
    var that = this
    var array = that.data.selectedArray;
    array[e.currentTarget.dataset.superid] = e.currentTarget.dataset.subid;
 
    that.setData({
      selectedArray: array
      
    })
  },
  clear: function (e) {

    var that = this
    var array = that.data.selectedArray;
    for (var i = 0; i < array.length; i++) {
      array[i] = -1;
    }
    
    that.setData({
      selectedArray: array

    })
  },
  sure: function (e) {

    var that = this
    that.closeView()
   
  },
  
  

})